#ifndef DOWNLOADER_H
#define DOWNLOADER_H

#include <QtGui/QMainWindow>
#include <QNetworkAccessManager>
#include <QNetworkReply>
#include "ui_downloader.h"

class Downloader : public QMainWindow
{
	Q_OBJECT

public:
	Downloader(QWidget *parent = 0, Qt::WFlags flags = 0);
	~Downloader();

signals:
	void downloadingStart();
	void downloadingProgress(int percentage);
	void downloadingEnd(QString message);

public slots:
	void beginDownload(QString downloadUrl);

protected slots:
	void addJSObject();
	void endDownloadFile();
	void progressDownloadFile(qint64 bytesReceived, qint64 bytesTotal);

protected:
	void abortDownload();

	QNetworkReply *downloadReply;
	QNetworkAccessManager *networkManager;
	QString downloadUrl, downloadLocalFilePath;

private:
	Ui::DownloaderMainWindow ui;
};

#endif // DOWNLOADER_H
